<?php
/**
 * Created by PhpStorm.
 * User: tjjs
 * Date: 17-7-18
 * Time: 上午10:26
 */

namespace ActionsHttp;

use Data\Order_form_DAO;
use Data\Reminder_order_form;
use Data\Reminder_order_form_DAO;

class ConsumerReminder extends BaseActionHttp
{
    public function doAction() {
        parent::doAction();
        // 订单id
        $order_form_id = (int)$this->data[ORDER_FORM_ID];
        // 订单记录
        $order_form_record = Order_form_DAO::getRecord($order_form_id);
        // 订单发起人
        $created_by = $order_form_record->getCREATED_BY();

        $_SESSION[CONSUMER_ID] = 1;

        if ($created_by != $_SESSION[CONSUMER_ID]) {
            // 非本人
            return $this->SendSessionOut();
        }


        if ($order_form_record->getIS_ENTRY()) {
            return $this->SendErrMsg("催单失败，订单已入帐");
        }
        if (($order_form_record->getPAY_STATUS()) != PAY_STATUS_YES) {
            return $this->SendErrMsg("催单失败，该订单未付款");
        }
        if (($order_form_record->getREMINDER_TIME()) && (time()-($order_form_record->getREMINDER_TIME()))<REMINDER_WAIT_TIME)
        {
            return $this->SendErrMsg("催单失败，您已催过单，暂时不能再次发起");
        }

        // 发起催单信息
        $order_form_record->setREMINDER_STATUS(REMINDER_STATUS_START);
        $order_form_record->setREMINDER_TIME(time());
        Order_form_DAO::update($order_form_record);

        // 返回数据
        $this->ResponseDataToCurrentClient();
    }
}